package com.atguigu.rabblitmq.rabbitmq;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class MQListener {
    //simple模型消费者
    @RabbitListener(

         bindings = @QueueBinding(
                 value = @Queue("spring.test.topic.queue"),
                 exchange = @Exchange(
                         value = "spring.test.topic.exchange",
                         type = ExchangeTypes.TOPIC
                 ),
                 key = {"*.orange.*"}

         )
    )
    public  void simpleListen(String msg, Channel channel, Message message) throws IOException {
        System.out.println("消费完毕:"+msg);
       channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }

}
